package com.hunliji.monitor.web.model.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

/**
 * user_info
 * @author
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class UserInfoVO {
    /**
     * 主键id
     */
    private Long id;

    /**
     * 花名
     */
    private String name;

    /**
     * 飞书user_id
     */
    private String feishuUserId;

    /**
     * 飞书用户openId
     */
    private String feishuOpenId;

    /**
     * 飞书unionId
     */
    private String feishuUnionId;

    /**
     * 电话
     */
    private String phone;

    /**
     * 邮件
     */
    private String mail;

    /**
     * 企微openId
     */
    private String workWechatOpenId;

    public static UserInfoVO getAtAllUserInfo(){
        return UserInfoVO.builder().feishuUserId("all").name("所有人").build();
    }

    public String takeFeishuUserId() {
        if(!StringUtils.isEmpty(feishuOpenId)){
            return feishuOpenId;
        }
        if(!StringUtils.isEmpty(feishuUnionId)){
            return feishuUnionId;
        }
        return feishuUserId;
    }

    public String takeFeishuUserIdType() {
        if(!StringUtils.isEmpty(feishuOpenId)){
            return "open_id";
        }
        if(!StringUtils.isEmpty(feishuUnionId)){
            return "union_id";
        }
        return "user_id";
    }
}
